<?php
/**
 * 生成二维码
 *
 * @param string $path 保存路径
 * @param string $url 连接
 * @param int $_size 图片大小
 * @param int $setPadding 二维码内边距
 * @param int $_level 级别
 * @throws DataDoesntExistsException
 * @throws FreeTypeLibraryMissingException
 * @throws ImageFunctionFailedException
 * @throws ImageFunctionUnknownException
 * @throws ImageSizeTooLargeException
 * @throws ImageTypeInvalidException
 * @throws ReflectionException
 * @throws VersionTooLargeException
 */
if (!function_exists('fish_qr_code')) {
    function fish_qr_code($path, $url, $_size = 200, $setPadding = 20, $_level = 6)
    {
        require_once __DIR__ . "/QrCode.php";
        $_qr = new QrCode();
        $text = urldecode($url);
        $_qr->setText($text);
        $_qr->setSize($_size);
        $_qr->setImageType(QrCode::IMAGE_TYPE_PNG);
        $_qr->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
        $_qr->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
        $_qr->setLabelFontSize($_level);
        $_qr->setErrorCorrection('high');
        $_qr->setPadding($setPadding);
        $_qr->save($path);
    }
}

